home *** CD-ROM | disk | FTP | other *** search
/ Internet Tools (InfoMagic) / Internet Tools.iso / news / moderating / ckngrps.shar.Z / ckngrps.shar / ckngrps
Text File  |  1993-11-22  |  3KB  |  133 lines

  1. #!/bin/sh
  2. #
  3. #  File Name:   ckngrps.sh
  4. #  Purpose  :   Determine if a Newsgroups: line contains entries for
  5. #               other moderated groups if crossposting.
  6. #  Usage    :   Edit the specific declarations below. 
  7. #
  8. #        from-within-mailer | ckngrps.sh
  9. #
  10. #  This script was written in about 30 minutes.  Please be kind...  
  11. #  It uses the article command from the rkive package.  If anyone
  12. #  needs a copy, let me know and I'll send it.  You should be able 
  13. #  to easily hack it to use grep but article commands were quicker 
  14. #  for me to write... ;-)  Quickly tested on a Sun SparcStation.
  15. #
  16. #        Kent Landfield
  17. #        kent@sparky.sterling.com
  18. #
  19. ###################################################################
  20. #
  21. # CHANGE THESE FOR YOUR SPECIFIC NEWSGROUP NEEDS
  22. #
  23. #set -x
  24. ME=kent@sparky.sterling.com
  25. MYGROUP=comp.sources.misc
  26.  
  27. # Location Variable declarations
  28.  
  29. ACTIVE=/usr/lib/news/active
  30. ARTICLE=/usr/local/bin/article
  31. TMPDIR=/usr/tmp
  32.  
  33. # Temp file 
  34.  
  35. TMPFILE=${TMPDIR}/ckngrps.$$
  36.  
  37. cat - > ${TMPFILE}
  38.  
  39. # cleanup
  40.  
  41. trap "rm -f ${TMPFILE}; exit 0"    0 1 2 15
  42.  
  43. #
  44. # Get the Newsgroups line from the article and
  45. # replace and ','s with blank spaces.
  46. #
  47.  
  48. set `${ARTICLE} -f "%N" ${TMPFILE} | sed "s/,/ /g"`
  49.  
  50. #
  51. # While we have newsgroups specified...
  52. #
  53.  
  54. num=0
  55. numbad=0
  56. while [ "$1" != "" ]
  57. do
  58.     num=`expr ${num} + 1`
  59.     #
  60.     # if its my group then I know about it so skip past it.
  61.     #
  62.     if [ "$1" != ${MYGROUP} ]
  63.     then
  64.         #
  65.         # Need to determine if the other group is moderated.
  66.         # Deal with multiple groups with the same partial name.
  67.         # I'm sure that there is a better way but this was cheap
  68.         # and sleezy.
  69.         #
  70.         mflag=`grep "^$1" ${ACTIVE} | awk '{ 
  71.             if ($1 == NG) {
  72.                 print $4
  73.                 break
  74.             }
  75.             else {
  76.                 printf "-"
  77.                 continue
  78.             }
  79.          }' NG=$1 `
  80.  
  81.         #
  82.         # if no match then skip the rest.
  83.         #
  84.  
  85.          if [ "${mflag}" = "-" ]
  86.         then
  87.             continue
  88.  
  89.         #
  90.         # Is it moderated ?
  91.         #
  92.          elif [ "${mflag}" = "m" ]
  93.         then
  94.             echo "WARNING: $1 is a moderated group! "
  95.             echo "   EDIT: $1 out of Newsgroups: line before posting!"
  96.             numbad=`expr ${numbad} + 1`
  97.         fi
  98.     fi
  99.     shift
  100. done
  101.  
  102. #
  103. # Everybody likes totals... :-)
  104. #
  105. echo "====="
  106. case ${num} in
  107.     0) echo "No Newsgroups Line encountered"
  108.        ;;
  109.     1) if [ ${numbad} -eq 1 ]; then
  110.         echo "Is this a posting for ${MYGROUP} ???"
  111.        fi
  112.        ;;
  113.     *) echo -n "Crossposting to ${num} groups, "
  114.        # 
  115.        # Correct usage of the English language never hurts... 
  116.        #
  117.            if [ ${numbad} -eq 1 ]; then
  118.            echo "${numbad} is moderated and should be corrected."
  119.        else
  120.             echo "${numbad} are moderated and should be corrected."
  121.        fi
  122.        ;;
  123. esac
  124.     
  125. # We're history.
  126. #
  127. echo
  128. echo -n "Press Return to continue:-> "
  129. read ans < /dev/tty
  130.  
  131. exit 0
  132.